package lab.gene.service.impl;

import java.util.Date;
import java.util.List;

import lab.gene.dao.GeneDAO;
import lab.gene.dao.GeneSecondStagePCRDAO;
import lab.gene.pojo.Gene;
import lab.gene.pojo.GeneSecondStagePCR;
import lab.gene.service.GeneSecondStagePCRService;
import lab.user.dao.UserDAO;
import lab.user.pojo.User;

public class GeneSecondStagePCRServiceImpl implements GeneSecondStagePCRService {

	@Override
	public void addGeneSecondStagePCR(String geneName, String userName,
			String stepType, Integer volume1, Integer volume2, Integer ml1,
			Integer ml2, Date recordDate, String comments) {
		// TODO Auto-generated method stub
		UserDAO udao = new UserDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		User u = udao.getUser(userName);
		
		GeneSecondStagePCR pcr = new GeneSecondStagePCR();
		pcr.setComments(comments);
		pcr.setDateModified(new Date());
		pcr.setGene(g);
		pcr.setMl1(ml1);
		pcr.setMl2(ml2);
		pcr.setRecordDate(recordDate);
		pcr.setStepType(stepType);
		pcr.setUser(u);
		pcr.setVolume1(volume1);
		pcr.setVolume2(volume2);
		
		GeneSecondStagePCRDAO dao = new GeneSecondStagePCRDAO();
		dao.addGeneSecondStagePCR(pcr);

	}

	@Override
	public GeneSecondStagePCR getGeneSecondStagePCR(String geneName,
			String stepType) {
		// TODO Auto-generated method stub
		GeneSecondStagePCR pcr = null;
		GeneSecondStagePCRDAO dao = new GeneSecondStagePCRDAO();
		GeneDAO gdao = new GeneDAO();
		Gene g = gdao.getGene(geneName);
		pcr = dao.getGeneSecondStagePCR(g, stepType);
		return pcr;
	}

	@Override
	public List<GeneSecondStagePCR> getGeneSecondStagePCRHistory(
			String geneName, String stepType) {
		// TODO Auto-generated method stub
		List<GeneSecondStagePCR> g = null;
		GeneSecondStagePCRDAO dao = new GeneSecondStagePCRDAO();
		GeneDAO gdao = new GeneDAO();
		Gene gene = gdao.getGene(geneName);
		g = dao.getGeneSecondStagePCRHistory(gene, stepType);
		return g;
	}

}
